package com.navinfo.platform.bigdata.dto;

import com.navinfo.platform.bigdata.util.EntityConvert;
import com.navinfo.stream.qingqi.protocol.java.LCPredictiveMaintenance;

public class MaintenanceEvent4Dto {
    private int flameout;
    private int oNGearStatus;
    private int ambientTemperature;
    private int stationaryLoopAir;
    private int frontLoopAir;
    private int rearLoopAir;

    public int getFlameout() {
        return flameout;
    }

    public void setFlameout(int flameout) {
        this.flameout = flameout;
    }

    public int getoNGearStatus() {
        return oNGearStatus;
    }

    public void setoNGearStatus(int oNGearStatus) {
        this.oNGearStatus = oNGearStatus;
    }

    public int getAmbientTemperature() {
        return ambientTemperature;
    }

    public void setAmbientTemperature(int ambientTemperature) {
        this.ambientTemperature = ambientTemperature;
    }

    public int getStationaryLoopAir() {
        return stationaryLoopAir;
    }

    public void setStationaryLoopAir(int stationaryLoopAir) {
        this.stationaryLoopAir = stationaryLoopAir;
    }

    public int getFrontLoopAir() {
        return frontLoopAir;
    }

    public void setFrontLoopAir(int frontLoopAir) {
        this.frontLoopAir = frontLoopAir;
    }

    public int getRearLoopAir() {
        return rearLoopAir;
    }

    public void setRearLoopAir(int rearLoopAir) {
        this.rearLoopAir = rearLoopAir;
    }

    public static MaintenanceEvent4Dto parseProto(LCPredictiveMaintenance.MaintenanceEvent4 maintenanceEvent4){
        MaintenanceEvent4Dto maintenanceEvent4Dto = new MaintenanceEvent4Dto();
        maintenanceEvent4Dto.setFlameout(maintenanceEvent4.getFlameout());
        maintenanceEvent4Dto.setoNGearStatus(maintenanceEvent4.getONGearStatus());
        maintenanceEvent4Dto.setAmbientTemperature(maintenanceEvent4.getAmbientTemperature());
        maintenanceEvent4Dto.setStationaryLoopAir(maintenanceEvent4.getStationaryLoopAir());
        maintenanceEvent4Dto.setFrontLoopAir(maintenanceEvent4.getFrontLoopAir());
        maintenanceEvent4Dto.setRearLoopAir(maintenanceEvent4.getRearLoopAir());
        return maintenanceEvent4Dto;
    }

    /**
     * 解析成String拼接字符串
     * @param maintenanceEvent4
     * @return
     */
    public static String parseString(LCPredictiveMaintenance.MaintenanceEvent4 maintenanceEvent4){
        return EntityConvert.convert(
                maintenanceEvent4.getFlameout(),
                maintenanceEvent4.getONGearStatus(),
                maintenanceEvent4.getAmbientTemperature(),
                maintenanceEvent4.getStationaryLoopAir(),
                maintenanceEvent4.getFrontLoopAir(),
                maintenanceEvent4.getRearLoopAir()
        );
    }

    /**
     * 反解析成PB对象
     * @param str
     * @return
     */
    public static LCPredictiveMaintenance.MaintenanceEvent4 parsePB(String str){
        LCPredictiveMaintenance.MaintenanceEvent4.Builder builder = null;

        try{
            String[] revert = EntityConvert.revert(str);
            if(null!=revert && revert.length>=5){
                builder = LCPredictiveMaintenance.MaintenanceEvent4.newBuilder();
                builder.setFlameout(Integer.valueOf(revert[0]));
                builder.setONGearStatus(Integer.valueOf(revert[1]));
                builder.setAmbientTemperature(Integer.valueOf(revert[2]));
                builder.setStationaryLoopAir(Integer.valueOf(revert[3]));
                builder.setFrontLoopAir(Integer.valueOf(revert[4]));
                builder.setRearLoopAir(Integer.valueOf(revert[5]));
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return builder==null? null : builder.build();
    }
}
